﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HuntWump2
{
    public partial class Form1 : Form
    {
        public List<Button> buttonz = new List<Button>();
        public static int i = 0;
        public Form1()
        {
            //triviawindow = new Form2();
            InitializeComponent();
            
             
            //Runs at start
                     
            //hide game elements
            gwee.hideButtons(this);
            pictureBox1.Hide();
            label1.Hide();
            label2.Hide();
            label3.Hide();
            label4.Hide();
            label5.Hide();
            button7.Hide();
            button8.Hide();
            button9.Hide();
            pictureBox3.Hide();
            pictureBox4.Hide();
            button15.Hide();
            pictureBox5.Hide();
            pictureBox6.Hide();
            pictureBox7.Hide();

            //hide high score elements
            label6.Hide();
            label8.Hide();
            label9.Hide();
            button14.Hide();

        }

        //direction buttons
        private void button1_Click(object sender, EventArgs e)
        {
            if (i == 0)
            {
                GameControl.turn(0);
            }
            else
            {
                GameControl.fireArrow(0);
            }
                updatescreen();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (i == 0)
            {
                GameControl.turn(1);
            }
            else
            {
                GameControl.fireArrow(1);
            }
            updatescreen();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (i == 0)
            {
                GameControl.turn(2);
            }
            else
            {
                GameControl.fireArrow(2);
            }
            updatescreen(); 
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (i == 0)
            {
                GameControl.turn(3);
            }
            else
            {
                GameControl.fireArrow(3);
            }
            updatescreen();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            
            if (i == 0)
            {
                GameControl.turn(4);
            }
            else
            {
                GameControl.fireArrow(4);
            }
            updatescreen();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (i == 0)
            {
                GameControl.turn(5);
            }
            else
            {
                GameControl.fireArrow(5);
            }
            updatescreen();
        }

        private void updatescreen()
        {
            showdoors();
            label4.Text = "Arrows: "+gwee.arrows;
            label1.Text = "Turns: " + gwee.turns;
            label3.Text = "Room: " + gwee.room;
            label5.Text = "Coins: " + gwee.coins;
            if (gwee.hazardz[0] == 0)
            {
                pictureBox5.Hide();
            }
            if (gwee.hazardz[1] == 0)
            {
                pictureBox6.Hide();
            }
            if (gwee.hazardz[2] == 0)
            {
                pictureBox7.Hide();
            }
            if (gwee.hazardz[0] == 1)
                {
                    MessageBox.Show("That humming sounds suspiciously like random transportation technology...");
                }
            if (gwee.hazardz[1] == 1)
                {
                    MessageBox.Show("Something smells like hazardous waste...");
                }
            if (gwee.hazardz[2] == 1)
                {
                    MessageBox.Show("...was that the wumpus?");
                }
            if (gwee.hazardz[0] == 2)
            {
                //pictureBox5.Show();
                MessageBox.Show("There should be a randomly transporting portal here.");
            }
            if (gwee.hazardz[1] == 2)
            {
                //pictureBox6.Show();
                MessageBox.Show("There should be a hazardous waste pit here.");
            }
            if (gwee.hazardz[2] == 2)
            {
                //pictureBox7.Show();
                MessageBox.Show("There should be a wumpus here...WAIT IT'S YOU");
            }

            

        }
        private void hidemenu()
        {
            button10.Hide();
            button11.Hide();
            button12.Hide();
            button13.Hide();
            pictureBox2.Hide();
            richTextBox1.Hide();
        }

        private void showdoors()
        {
            gwee.hideButtons(this);
            for (int i = 0; i < gwee.doorshow.Length; i++)
            {
                if (gwee.doorshow[i] == 1)
                {
                    buttonz[i].Show();
                    buttonz[i].Text = gwee.chooseStatement(i);
                }
            }
            //create a form that shows trivia stuff 
        }

        //buy secret
        private void button7_Click(object sender, EventArgs e)
        {
            GameControl.turn('s');
            updatescreen();
        }
        //buy arrow
        private void button8_Click(object sender, EventArgs e)
        {
            GameControl.turn('a');
            pictureBox3.Show();
            pictureBox4.Show();
            button15.Show();
            
        }
        //shoot arrow
        private void button9_Click(object sender, EventArgs e)
        {
            GameControl.turn('f');
            updatescreen();
        }
        //exit
        private void button13_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        //show high scores
        private void button12_Click(object sender, EventArgs e)
        {
            hidemenu();
            label6.Show();
            button14.Show();
            HighScore.addHighScore("name", 0);
            label8.Text = "";
            label9.Text = "";
            for (int i = 0; i < 20; i+=2)
            {
                label8.Text += HighScore.getScores()[i]+"\n\n";
                label9.Text += HighScore.getScores()[i + 1] + "\n\n";
            }
            label8.Show();
            label9.Show();
        }
        //start game
        private void button10_Click(object sender, EventArgs e)
        {
            hidemenu();
            buttonz.Add(button1);
            buttonz.Add(button4);
            buttonz.Add(button2);
            buttonz.Add(button5);
            buttonz.Add(button3);
            buttonz.Add(button6);
            GameControl.gameControl();
            GameControl.newGame(richTextBox1.Text);
            updatescreen();
            pictureBox1.Show();
            label1.Show();
            label2.Show();
            label3.Show();
            label4.Show();
            label5.Show();
            button7.Show();
            button8.Show();
            button9.Show();
        }

        private void button14_Click(object sender, EventArgs e)
        {
            button10.Show();
            button11.Show();
            button12.Show();
            button13.Show();
            pictureBox2.Show();
            richTextBox1.Show();
            label6.Hide();
            label8.Hide();
            label9.Hide();
            button14.Hide();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            Form2 instructions = new Form2();            
            instructions.Show();           
        }

        public static void exitwindow(Form trivea)
        {
            trivea.Hide();
        }

        private void button15_Click(object sender, EventArgs e)
        {
            button15.Hide();
            pictureBox3.Hide();
            pictureBox4.Hide();
            updatescreen();
        }
    }
}
